package testTP4;

import org.junit.*;
import static org.junit.Assert.*;
import firewall.*
import firewallConfig.*

class TestForward {
	
	@Test
	public void testeaForweardeoDeUnPaquete() {
		Firewall firewall =
		FirewallBuilder.configurar {
			regla {
				ip "DESTINO"
					abrir "192.168.2.1" a "192.168.2.10"
				forward("192.168.2.20",80)
			}
		}
		
		FirewallMock mock = new FirewallMock();
		mock.agregarFirewall(firewall);
		
		Paquete paquete = new Paquete("200.32.232.21","192.168.2.5",80);
		assertTrue(firewall.evaluaPaquete(paquete));
		
		// Forwardea
		assertEquals(paquete.getIpDestino(), 192168220);
		assertEquals(paquete.getPuerto(),80);
		
		paquete = new Paquete("200.32.232.21","192.168.2.100",700);
		assertTrue(firewall.evaluaPaquete(paquete));
		
		// No forwardea
		assertEquals(paquete.getIpDestino(), 1921682100);
		assertEquals(paquete.getPuerto(),700);
		
		
	}
	
}
